﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace RRQMSocketServer.common
{
    class R
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public int Code;
        /// <summary>
        /// 消息
        /// </summary>
        public string Message;
        /// <summary>
        /// 数据
        /// </summary>
        public object Data;
        public static string OK()
        {
            R r = new R
            {
                Code = 0,
                Message = "请求成功"
            };
            return JsonConvert.SerializeObject(r);
        }
        public static string OK<T>(T data) {
            R r = new R
            {
                Code = 0,
                Message = "请求成功",
                Data = data
            };
            return JsonConvert.SerializeObject(r);
        }
        public static string Error(string message)
        {
            R r = new R
            {
                Code = 1,
                Message = message
            };
            return JsonConvert.SerializeObject(r);
        }
    }
}
